-
Notifications
You must be signed in to change notification settings - Fork 896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds screenshot options to context menu and commands #27083
base: master
Are you sure you want to change the base?
Conversation
0e69a8a
to
4b7451d
Compare
I've refactored this into a TabHelper pattern, with deferred attachment (until user requests a screenshot). Commits landing here in a bit. |
Make sure you follow the latest updates using TabInterface and not WebContentsUserData |
Looking into that now. Thanks! |
22868e1
to
fdd6104
Compare
chromium_src/chrome/browser/renderer_context_menu/render_view_context_menu.cc
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm % nits
By using a browser reference we can avoid the reliance on global methods to look up a window from a given webcontents instance.
Removed the helper "TakeScreenshot" method which originally existed to stand up and instance of the helper. Now that the helper is a proper tab feature, we can use it as such from context menu commands and elsewhere.
If there is nothing selected, we shouldn't attempt to construct an autocomplete match, run the autocomplete classifier, etc. Furthermore, this enables us to simplify tests involving the context menu due to reduced setup.
f8c8d02
to
6d39b1e
Compare
After rebasing, there is now a failure in this PR unrelated to the contents or changes introduced by the PR itself. A fresh build from scratch will resolve this, but a component build will proceed if any change is made to the policy template file. As such, a typo has been found and fixed so as to 1) Improve the comments, and importantly 2) Fix the build 😀 See https://bravesoftware.slack.com/archives/C7VLGSR55/p1736928018175489?thread_ts=1736911378.517619&cid=C7VLGSR55 for more info.
] | ||
|
||
deps = [ | ||
"//chrome/browser/image_editor:image_editor", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be just //chrome/browser/image_editor
same as "//chrome/browser/ui
and //ui/base/clipboard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I purposefully provide the target names, just to more clearly communicate intent. If it's okay, I'd prefer to keep them explicit.
[puLL-Merge] - brave/brave-core@27083 DescriptionThis PR introduces screenshot functionality to the Brave browser, allowing users to capture full-page, viewport, or selected area screenshots directly from the browser's context menu. The feature is gated behind a feature flag and includes new command IDs, UI strings, and implementation files for different screenshot strategies. ChangesChanges
sequenceDiagram
participant User
participant ContextMenu
participant BraveScreenshotsTabFeature
participant ScreenshotStrategy
participant DevTools
participant Clipboard
User->>ContextMenu: Right-click and select screenshot option
ContextMenu->>BraveScreenshotsTabFeature: StartScreenshot
BraveScreenshotsTabFeature->>ScreenshotStrategy: Create strategy
ScreenshotStrategy->>DevTools: Capture screenshot (if full-page)
DevTools-->>ScreenshotStrategy: Return screenshot data
ScreenshotStrategy-->>BraveScreenshotsTabFeature: Return capture result
BraveScreenshotsTabFeature->>Clipboard: Copy image to clipboard
BraveScreenshotsTabFeature->>User: Display screenshot bubble
Possible Issues
Security Hotspots
|
Resolves brave/brave-browser#25816
Security/Privacy Review: https://github.com/brave/reviews/issues/1831
screenshot-context-menu.mp4
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
Once a screenshot has been taken, you should see a UI element (with a preview of your screenshot) informing you that the screenshot has been copied to your device's clipboard.